export const authServiceUrl = "http://cas.cqzhxy.cn/cas?service=";
export const getTickit = () => {
  let parameters = window.location.search;
  // 如果没有参数
  if (parameters.indexOf("?") == -1) return null;
  let strs = parameters.substr(1).split("&");
  for (let i = 0; i < strs.length; i++) {
    let str = strs[i].split("=");
    // map.set(str[0], str[1]);
    if (str[0] === "ticket") {
      return str[1];
    }
  }
  return "";
};

export const authRedict = (addr: string) => {
  const ticket = getTickit() || "";
  if (ticket === "") {
    window.location.replace(authServiceUrl + addr);
  }
};
